import { request } from '@/app/http'
import { encrypt } from '@/utils'

const PATH = '/student'

export function updateInfo(data) {
  return request({
    url: PATH + '/updateInfo',
    method: 'put',
    data,
    showMsg: true
  })
}

export function updateStudentPass(data) {
  const { oldPass, newPass, confirmPass } = data
  if (newPass !== confirmPass) {
    return Promise.reject({ msg: '确认密码和新密码不一致' })
  }
  return request({
    url: PATH + '/updatePass',
    method: 'post',
    data: {
      oldPass: encrypt(oldPass),
      newPass: encrypt(newPass)
    }
  })
}
